---
description: "Reference for Nitric's Dart library - Returns a reference to a known version of a secret."
---

# Dart - secret.version()

<Note>
  This is reference documentation for the Nitric Dart SDK. To learn about
  Secrets in Nitric start with the [Secrets docs](/secrets).
</Note>

Returns a reference to a known version of a secret.

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("encryptionKey").allow([
  SecretPermission.access,
]);

final keyVersionRef = keyRef.version("the-version-id");
```

## Parameters

<Properties>
  <Property name="version" required type="String">
    The version ID. This value is returned from [secret.put()](./secret-put).
  </Property>
</Properties>

## Examples

### Return a reference to a known secret version

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("encryptionKey").allow([
  SecretPermission.access,
]);

final keyVersionRef = keyRef.version("the-version-id");
```

### Access the value of a known secret version

```dart
import 'package:nitric_sdk/nitric.dart';

final keyRef = Nitric.secret("encryptionKey").allow([
  SecretPermission.access,
]);

final keyValue = await keyRef.version("the-version-id").access();
```

### See also

- [secret.version().access()](./secret-version-access)
